<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.controller' );class LettermanControllerCampaign extends JController
{
	
	function form()
	{
		JRequest::setVar('tmpl', 'component');
		parent::display();
	}
	
	function add()
	{
		$this->form();
	}
	
	function save()
	{
		global $mainframe;

		// Security Check
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$campaign = JRequest::get('post');

		$model = $this->getModel('campaign');

		if ($model->store($campaign)) {
			$msg = JText::_( 'Campaign Saved' );
		} else {
			$msg = JText::_( "D'oh!.... campaign did not save." );
		}
		//$model->checkin();
		
		$this->setRedirect('index.php?option=com_letterman&view=campaigns', $msg);
	}
	
	function deleteForm()
	{
		global $mainframe;
		
		JRequest::setVar('tmpl', 'component');
		
		parent::display();	
	}
	
	function delete()
	{
		global $mainframe;

		$model = $this->getModel('campaign');

		if ($model->delete($id)) {
			$msg = JText::_( 'Campaign Deleted' );
		} else {
			$msg = JText::_( "D'oh!.... campaign did not delete." );
		}

		$this->setRedirect('index.php?option=com_letterman&amp;view=campaigns', $msg);
		
	}
	
	function publish()
	{
		global $mainframe;

		$model = $this->getModel('campaign');

		if ($model->publish($campaign)) {
			$msg = JText::_( 'Campaign Published' );
		} else {
			$msg = JText::_( "D'oh!.... campaign did not publish." );
		}
		
		$this->setRedirect('index.php?option=com_letterman&amp;view=campaigns', $msg);
	}

}
?>